<!DOCTYPE html>
<html lang="zh_CN">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div id="app">
    <p>vue2的基本使用</p>

    <ul>
        <li v-for="ele in userInfo">{{ ele }}</li>
    </ul>

    <button @click="changeHandler">操作数据</button>

</div>
</body>
<script src="js/vue2.js"></script>

<script type="text/javascript">

    const vm = new Vue({
        el: '#app',
        data: {
            userInfo: {
                id: 12,
                name: 'andy',
                age: 23,
                work: {
                    name: 'pm',
                    skills: ['vue', 'react'],
                }
            }
        },
        methods: {
            changeHandler() {
                console.log('changeHandler');
                // this.userInfo.age += 1;
                // this.userInfo.nickName = 'mark';
                // this.$set(this.userInfo, 'nickName', 'mark');

                // delete this.userInfo.name;
                // this.$delete(this.userInfo, 'name');

                // this.userInfo.work.skills[0] = 'Vue';
                this.$set(this.userInfo.work.skills, 0, 'Vue');
            }
        }
    })

    console.log(vm.$data);

</script>

</html>
